<?php
//filename : laporandp3.php
require_once APPPATH.'controllers/gnc_mng'.EXT;

class LAPORANDP3 extends Gnc_mng {
	protected $model_path	= 'dpt/m_penilai_dp3';
	protected $model_dp3	= 'dpt/m_dp3';
	protected $model_pegawai = 'dpt/m_pegawai';
	protected $model_nilai = 'dpt/m_nilai_dp3_rinci';
	protected $model_detail_dp3 = 'dpt/m_d_dpt';
	protected $model_header_dp3 = 'dpt/m_penilaih_dp3';
	protected $model_view_nilaidp3 = 'dpt/m_v_nilaidp3';

	function index()
	{
		// get all user data
		$namauser =  $this->session->userdata('user');
		
		$record = $this->load->model($this->model_pegawai)->select_query(array('nip'),array('key_sys_user' => $namauser),null);
		$nip = $record[0]->nip;
		
		// Cek 
		if ($namauser == 'good'){	
			$data = array(
				'application' => $prefix,
				'application_title' => $this->common->get_application_description($prefix),
				'page' => 'Daftar Pegawai',
				'navigation' => $this->load->view('dpt/nav/general', '', TRUE),
				'content' => $this->load->view('dpt/viewer/penilai', array('content'=>$content), TRUE),
			);	// data yang akan dipassing ke view

			$this->load->view('layout/default', $data);
		} else {
			// get all user data
			$namauser =  $this->session->userdata('user');
			$record = $this->load->model($this->model_pegawai)->select_query(array('nip'),array('key_sys_user' => $namauser),null);
			$nip = $record[0]->nip;
			///$nip = '18118220030701';
			
			$record = $this->load->model($this->model_view_nilaidp3)->select_query(array('nip'),array('nip' => $nip),null);

			$pegawai = $this->load->model($this->model_pegawai)->select_query(null,array('nip' => $nip),null);
			$ket = $this->load->model($this->model_dp3)->select_query();
			
			//print_r($record);
			$data = array(
				'application' => $prefix,
				'application_title' => $this->common->get_application_description($prefix),
				'page' => 'Approve Nilai DP3',
				'navigation' => $this->load->view('dpt/nav/general', '', TRUE),
				'content' =>  $this->load->view('dpt/form/formulir_approvedp3', array('record'=>$record[0],'ket'=>$ket,'pegawai'=>$pegawai[0]), TRUE),
			);	// data yang akan dipassing ke view
			
			$this->load->view('layout/default', $data);	
		}		
	}
		
	function process_approve()
	{
		$nilai	= $_POST['nilaiharapan'];
		$id_dp3 = $_POST['id_dp3'];
		
		$this->db->query("UPDATE dpt_d_dp3 SET nilai_approved = '$nilai' WHERE id_dp3 ='$id_dp3'");
				
		$data = array(
			'application' => $prefix,
			'application_title' => $this->common->get_application_description($prefix),
			'page' => 'Index',
			'navigation' => $this->load->view('dpt/nav/general', '', TRUE),
			//'content' =>   $this->load->view('dpt/viewer/main','' ,TRUE),
		);	// data yang akan dipassing ke view
		
		$this->load->view('layout/default', $data);	
	}

	
}